<template>
    <div class="home">
        <div class="header">

            <div class="dh-container">
                <li>
                    <div class="logo">
                    </div>
                </li>
                <li>
                    <div class="dhBox" @click="qhclick(1)"
                        :style="qhIndex === 1 ? 'background-color: #ccc;border-bottom: 2px solid rgb(0, 184, 55);color: rgb(0, 184, 55); ' : ''">
                        首页
                    </div>
                </li>
                <li>
                    <div class="dhBox" @click="qhclick(2)"
                        :style="qhIndex === 2 ? 'background-color: #ccc;border-bottom: 2px solid rgb(0, 184, 55);color: rgb(0, 184, 55); ' : ''">
                        查询景点</div>
                </li>
                <li>
                    <div class="dhBox" @click="qhclick(3)"
                        :style="qhIndex === 3 ? 'background-color: #ccc;border-bottom: 2px solid rgb(0, 184, 55);color: rgb(0, 184, 55); ' : ''">
                        查询攻略</div>
                </li>
                <li>
                    <div class="dhBox" @click="qhclick(4)"
                        :style="qhIndex === 4 ? 'background-color: #ccc;border-bottom: 2px solid rgb(0, 184, 55);color: rgb(0, 184, 55); ' : ''">
                        查询票据</div>
                </li>
                <li>
                    <div class="dhBox" @click="qhclick(5)"
                        :style="qhIndex === 5 ? 'background-color: #ccc;border-bottom: 2px solid rgb(0, 184, 55);color: rgb(0, 184, 55); ' : ''">
                        个人中心</div>
                </li>
            </div>
            <div class="user" v-if="this.name === null">
                <button class="button" @click="goLogin">Login in</button>
            </div>
            <div class="user" v-if="this.name !== null">
                <div
                    style="height:50px;width: 300px;background-color: #eee;line-height: 50px;border-radius: 5px;margin-top: 5px;f">
                    欢迎用户{{ this.name }}登录本网站
                </div>

            </div>
        </div>
        <div>
            <router-view></router-view>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            qhIndex: 1,
            name: "",
            token: '',
        }
    },
    mounted() {
        this.qhIndex = localStorage.getItem("index");
        this.token = localStorage.getItem("token");
        this.name = localStorage.getItem("username");
    },
    methods: {
        /**根据点击的导航栏做跳转判断 */
        qhclick(index) {
            console.log(index);
            this.qhIndex = index;
            if (index == 1) {
                localStorage.index = 1;
                this.$router.push({
                    path: '/travel'
                })
            } else if (index == 2) {
                localStorage.index = 2;
                this.$router.push({
                    path: '/spotview'
                })
            } else if (index == 3) {
                localStorage.index = 3;
                this.$router.push({
                    path: '/guideview'
                })
            } else if (index == 4) {
                localStorage.index = 4;
                this.$router.push({
                    path: '/ticketview'
                })
            }
            else if (index == 5) {
                localStorage.index = 5;
                this.$router.push({
                    path: '/usercenter'
                })
            }
        },
        goLogin() { this.$router.push({ path: '/login' }) }
    }
}
</script>
<style scoped>
.home {
    width: 100%;
    height: 100%;
}

.logo {
    width: 100px;
    height: 60px;
    float: left;
    margin-left: 30px;
}

.header {
    width: 100%;
    height: 60px;
    background-color: #eee;
    display: flex;
    justify-content: space-around;
}

.header li {
    list-style: none;
    float: left;
}

.dh-container {
    /* margin-left: 400px; */
    margin: 0 10px;
}

.dhBox {
    width: 100px;
    height: 58px;
    line-height: 58px;
    text-align: center;
    float: left;
    margin-left: 20px;
    cursor: pointer;
    transition: all .5 linear;
}

.dhBox:hover {
    background-color: #ccc;
    color: rgb(0, 184, 55);
    border-bottom: 2px solid rgb(0, 184, 55);
}

.user {
    position: relative;
    float: right;
}

.input-container {
    position: relative;
    /* float: right; */
    width: 260px;
    margin: 20px 180px;
}

.input-container input[type="text"] {
    font-size: 16px;
    width: 100%;
    border: none;
    border-bottom: 2px solid #ccc;
    padding: 5px 0;
    background-color: transparent;
    outline: none;
}

.input-container .label {
    position: absolute;
    top: 0;
    left: 0;
    color: #ccc;
    transition: all 0.3s ease;
    pointer-events: none;
}

.input-container input[type="text"]:focus~.label,
.input-container input[type="text"]:valid~.label {
    top: -15px;
    font-size: 13px;
    color: rgb(0, 184, 55);
}

.input-container .underline {
    position: absolute;
    bottom: -10px;
    left: 0;
    height: 2px;
    width: 100%;
    background-color: rgb(0, 184, 55);
    transform: scaleX(0);
    transition: all 0.3s ease;
}

.input-container input[type="text"]:focus~.underline,
.input-container input[type="text"]:valid~.underline {
    transform: scaleX(1);
}

.button {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    margin-top: 10px;
    text-transform: uppercase;
    color: #fff;
    background-color: #3dda5f;
    border: none;
    border-radius: 50px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.button::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-color: rgba(64, 255, 105, 0.247);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.4s ease;
    z-index: -1;
}

.button::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
    background-size: 30px 30px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.button:hover {
    background-color: #17772f;
    transform: scale(1.1) rotate(1deg);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.3);
}

.button:hover::before {
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%) rotate(10deg);
}

.button:hover::after {
    opacity: 1;
}

.button:active {
    background-color: #1c8f3e;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transform: translateY(2px);
}
</style>